home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1990: Night of the Living Disc / Night of the Living Disc.2mg / Dev.CD.5 / Tools / DTS.Samples / SC09Lister / Start.c < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-25  |  2.5 KB  |  103 lines  |  [B0] Apple IIgs Source Code (0x000A)

  1. /**********************************************************************
  2. *
  3. * lister start.c -- Version 3.0
  4. *
  5. * Developer Technical Support Apple II Sample Code
  6. *
  7. * Copyright (c)
  8. * Apple Computer, Inc.  1988-1990
  9. * All Rights Reserved.
  10. *
  11. * Written by Eric Soldan.
  12. *
  13. * This file contains the code needed to start (and quit) lister.
  14. *
  15. **********************************************************************/
  16.  
  17. #include <types.h>
  18. #include <quickdraw.h>
  19. #include <loader.h>
  20. #include <locator.h>
  21. #include <memory.h>
  22.  
  23. #include "lister.h"
  24.  
  25. void    doFmdStartUp();
  26. void    doFmdShutDown();
  27.  
  28. #ifdef __fmdTool__
  29. static InitialLoadOutputRec     fmdInfo;
  30. #endif
  31.  
  32. /*********************************************************************/
  33.  
  34. main()
  35. {
  36.     Ref     initRef;    /* This holds the reference to the startstop record */
  37.  
  38.     TLStartUp();
  39.     MMStartUp();
  40.     initPtrCheck(_ownerid);
  41.  
  42.     initRef = StartUpTools(_ownerid, refIsResource, 0x0001L);
  43.         /* Start up the tools using the new toolbox call */
  44.  
  45.     if (!_toolErr) doFmdStartUp();      /* Start up fakeModalDialog.   */
  46.     if (!_toolErr) initGlobals();       /* Initialize our globals.     */
  47.     if (!_toolErr) setupMenus();        /* Set up menus.               */
  48.     if (!_toolErr) InitCursor();        /* Make cursor show ready.     */
  49.     if (!_toolErr) mainEvent();         /* Use application.            */
  50.  
  51.     doFmdShutDown();
  52.     ShutDownTools(refIsHandle, initRef);
  53.         /* Let the toolbox shut down the tools. */
  54.  
  55.     closePtrCheck();
  56.     MMShutDown(_ownerid);
  57.     TLShutDown();
  58. }
  59.  
  60. /*********************************************************************/
  61.  
  62. void    doFmdStartUp()
  63. {
  64.     unsigned int    tempID, err;
  65.     static char     fmdName[] = "\p9:FakeModalTool";
  66.  
  67. #ifdef __fmdTool__
  68.  
  69.     fmdInfo.userID = 0;             /* In case we fail.                */
  70.  
  71.     tempID = GetUserID(fmdName);    /* Get old ID for the toolset, if any. */
  72.  
  73.     if (!_toolErr) fmdInfo = Restart(tempID);
  74.     if (_toolErr)  fmdInfo = InitialLoad(0x1000, fmdName, 0);
  75.  
  76.     if (err = _toolErr) {
  77.         InitCursor();
  78.         TLMountVolume(40, 32, "\pYou need fakeModalTool in same",
  79.             "\pfolder as lister.", "\pAgain", "\pCome");
  80.         _toolErr = err;
  81.     }
  82.     else SetTSPtr(userTool, fmdToolNum, fmdInfo.startAddr);
  83.  
  84. #endif
  85.  
  86.     if (!_toolErr) fmdStartUp();
  87. }
  88.  
  89. /*********************************************************************/
  90.  
  91. void    doFmdShutDown()
  92. {
  93.     fmdShutDown();
  94.  
  95. #ifdef __fmdTool__
  96.  
  97.     if (fmdInfo.userID)
  98.         UserShutDown(fmdInfo.userID, 0x4000);   /* restartable from memory */
  99.  
  100. #endif
  101.  
  102. }
  103.